package com.wande.dataplatform.controller;

import com.wande.common.core.domain.R;
import com.wande.common.web.core.BaseController;
import com.wande.dataplatform.domain.vo.DashboardStatsVO;
import com.wande.dataplatform.service.IDashboardService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 数据中台首页统计控制器
 *
 * @author dataplatform
 */
@Tag(name = "数据中台首页统计", description = "数据中台首页统计相关接口")
@RestController
@RequestMapping("/dataplatform/dashboard")
@RequiredArgsConstructor
public class DashboardController extends BaseController {

    private final IDashboardService dashboardService;

    /**
     * 获取数据中台首页统计数据
     */
    @Operation(summary = "获取数据中台首页统计数据")
    @GetMapping("/stats")
    public R<DashboardStatsVO> getDashboardStats() {
        DashboardStatsVO stats = dashboardService.getDashboardStats();
        return R.ok(stats);
    }

    /**
     * 获取数据源统计
     */
    @Operation(summary = "获取数据源统计")
    @GetMapping("/stats/datasource")
    public R<DashboardStatsVO.DataSourceStats> getDataSourceStats() {
        DashboardStatsVO.DataSourceStats stats = dashboardService.getDataSourceStats();
        return R.ok(stats);
    }

    /**
     * 获取项目统计
     */
    @Operation(summary = "获取项目统计")
    @GetMapping("/stats/project")
    public R<DashboardStatsVO.ProjectStats> getProjectStats() {
        DashboardStatsVO.ProjectStats stats = dashboardService.getProjectStats();
        return R.ok(stats);
    }

    /**
     * 获取作业统计
     */
    @Operation(summary = "获取作业统计")
    @GetMapping("/stats/job")
    public R<DashboardStatsVO.JobStats> getJobStats() {
        DashboardStatsVO.JobStats stats = dashboardService.getJobStats();
        return R.ok(stats);
    }

    /**
     * 获取数据资产统计
     */
    @Operation(summary = "获取数据资产统计")
    @GetMapping("/stats/asset")
    public R<DashboardStatsVO.AssetStats> getAssetStats() {
        DashboardStatsVO.AssetStats stats = dashboardService.getAssetStats();
        return R.ok(stats);
    }

    /**
     * 获取数据质量统计
     */
    @Operation(summary = "获取数据质量统计")
    @GetMapping("/stats/quality")
    public R<DashboardStatsVO.QualityStats> getQualityStats() {
        DashboardStatsVO.QualityStats stats = dashboardService.getQualityStats();
        return R.ok(stats);
    }

    /**
     * 获取元数据统计
     */
    @Operation(summary = "获取元数据统计")
    @GetMapping("/stats/metadata")
    public R<DashboardStatsVO.MetadataStats> getMetadataStats() {
        DashboardStatsVO.MetadataStats stats = dashboardService.getMetadataStats();
        return R.ok(stats);
    }

    /**
     * 获取数据服务统计
     */
    @Operation(summary = "获取数据服务统计")
    @GetMapping("/stats/api")
    public R<DashboardStatsVO.ApiStats> getApiStats() {
        DashboardStatsVO.ApiStats stats = dashboardService.getApiStats();
        return R.ok(stats);
    }

    /**
     * 获取存储统计
     */
    @Operation(summary = "获取存储统计")
    @GetMapping("/stats/storage")
    public R<DashboardStatsVO.StorageStats> getStorageStats() {
        DashboardStatsVO.StorageStats stats = dashboardService.getStorageStats();
        return R.ok(stats);
    }
}